import service from '@/assets';
import { evnConfigPath,dateFormat } from "@/assets/utils";

export default {
    //上传excel
    haibeiServerUploadFile(formData,action) {
        let config = {
            headers: {
                'Content-Type': 'multipart/form-data'
            },
            transformRequest: [function(data, headers) {
                return data;
            }],
        }
        return service
            .post(action+'.action', formData, config)
            .then(res => res.data).catch(error => { console.log(error) });
    },
    //上传图片 
    uploadImageService(params) {
        let config = {
            headers: {
                'Content-Type': 'multipart/form-data',
            },
            transformRequest: [function(data) {
                return data;
            }],
        }
        return service.post('uploadImg.action', params, config).then(res => res.data).catch(error => { console.warn(error) })
    },
    // 普通上传
    haibeiServerUpload() {
        return evnConfigPath('upload')
    },
    //导出-公共调用
    haiBeiServerDownloadExel( name) {
       
        let url = evnConfigPath('export') + name ;
        let downloadID = document.getElementById("downloadRechargeList");

        if (downloadID) {
            downloadID.setAttribute("href", url);
            downloadID.click();
        } else {
            let createA = document.createElement("a");
            createA.style.display = "none";
            createA.setAttribute("id", "downloadID");
            createA.setAttribute("href", url);
            createA.setAttribute("target", "_black");
            document.body.appendChild(createA);
            setTimeout(() => {
                createA.click();
            }, 400);
        }
    },

}